package com.zidian.study.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.zidian.study.globa.Constant;

/**
 * Created by Administrator on 2016/9/13 0013.
 */
public class GetUserInfo {

    public static String getStudentId(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.USER_INFO_KEY, Context.MODE_PRIVATE);
        return sharedPreferences.getString("studentId", "");
    }

    public static String getStudentName(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.USER_INFO_KEY, Context.MODE_PRIVATE);
        return sharedPreferences.getString("studentName", "");
    }

    public static String getToken(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.USER_INFO_KEY, Context.MODE_PRIVATE);
        return sharedPreferences.getString("token", "");
    }

    public static String getAccount(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.USER_INFO_KEY, Context.MODE_PRIVATE);
        return sharedPreferences.getString("account", "");
    }

    public static void loginOut(Context context) {
        SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.USER_INFO_KEY, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();//获取编辑器
        editor.putString("studentName", "");
        editor.putString("token", "");
        editor.putBoolean("isLogin", false);
        editor.putString("password", "");
        editor.commit();
    }


}
